<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript" src="js/ddm.js"></script>
<script>
function CheckCheckAll(Check_ctr) {
	chk = document.getElementsByName('selectedCategory');
	if (Check_ctr.checked == true) {
		chk.checked = true;
		for (i = 0; i < chk.length; i++) {
			chk[i].checked = true;
		}
	} else {
		chk.checked = false;
		for (i = 0; i < chk.length; i++) {
			chk[i].checked = false;
		}
	}
}

function deleteUser() {
	var flag = false;
	chk = document.getElementsByName('selectedCategory');
	for (i = 0; i < chk.length; i++) {
		if(chk[i].checked == true) {
			flag = true;
			break;
		}
	}

	if(flag) {
		return wantToDelete('Want to delete selected users?');
	} else {
		alert('Select at least one user to delete...');
		return false;
	}
}
</script>

<table width="100%">
	<tr>
		<td>
			<div class="blue-text16" style="margin: 0px 0px 0px 0px">
				<table width="100%">
					<tr>
						<td class="heding" align="left">
							<s:text name="user_header" />
						</td>

						<td align="left">
							<a href="addToFavoriteUsers.htm" class="common-link"><s:text name="lable.addfavoriteuser" /></a>
						</td>
					</tr>
				</table>
			</div>
			<div class="header-separator-bg" style="margin: 10px 5px 17px 0px"></div>
			<div style="margin: 0px 0px 12px 0px">

				<s:form action="deleteMultiFavoriteUser.htm" theme="simple" onsubmit="return deleteUser()">

				<table border="0" cellpadding="0" cellspacing="0" width="100%">
					<tbody>
						<tr>
							<td>
								<display:table name="favoritesUsersList" pagesize="10" requestURI="favoriteUsers.htm" id="row" >
									<display:column title="<input type='checkbox' name='selectall' onclick='CheckCheckAll(this)' />" style="width: 5%; text-align: center" class="grid-bg common-text" headerClass="grid-header-bg grid-header-text-link">
										<s:checkbox name="selectedCategory" theme="simple" fieldValue="%{#attr.row.id}" />
									</display:column>
									<display:column value="${row.userIdFav.userId}" style="width: 50%" class="grid-bg common-text" headerClass="grid-header-bg grid-header-text-link" title="Users" href="browseItems.htm" paramId="uid" paramName="${row.userIdFav.id}" autolink="true" sortable="true" />
									<display:column value="${row.userIdFav.country.categoryName}" style="width: 10%" class="grid-bg common-text" headerClass="grid-header-bg grid-header-text-link" title="Location"  />
									<display:column title="Added" style="width: 25%" class="grid-bg common-text" headerClass="grid-header-bg grid-header-text-link">
										<s:date name="%{#attr.row.date}" format="%{#attr.user.dateFormat.format}" />
									</display:column>
									<display:column class="grid-bg common-text" style="width: 10%" title="Option" headerClass="grid-header-bg grid-header-text-link">
										<table>
											<tr>
												<td align="center" valign="top" class="grid-bg common-text" id="mddm" width="10%">
													<a class="mddm" href="#" onmouseover="mopen('<s:property value="%{#attr.row.id}"/>', this, 'common-link', 'right', 1)"
														onmouseout="mclosetime()">Select</a>
													<div style="visibility: hidden;" id="<s:property value="%{#attr.row.id}"/>"
														onmouseover="mcancelclosetime()"
														onmouseout="mclosetime()">
														<s:a href="javascript: wantToDeleteWithURL('deleteFavoriteUsers.htm?uid=%{#attr.row.id}', 'Do you want to delete this user?')">Delete</s:a>
													<s:if test="#attr.row.note != null && #attr.row.note != ''">
														<s:a href="addEditNoteToFavoriteUsers.htm?fuid=%{#attr.row.id}">Edit Note</s:a>
													</s:if>
													<s:else>
														<s:a href="addEditNoteToFavoriteUsers.htm?fuid=%{#attr.row.id}">Add Note</s:a>
													</s:else>
														<s:a href="viewSellersOtherItems.htm?userId=%{#attr.row.userIdFav.id}&action=favoriteUsers">View sellers other items</s:a>
														<s:a href="mailto:%{#attr.row.userIdFav.email}">Contact</s:a>
														<a href="browseItems.htm?uid=<s:property value="%{#attr.row.userIdFav.id}" />&type=6">Company profiles</a>
														<s:a href="browseItems.htm?uid=%{#attr.row.userIdFav.id}&type=4">Items wanted</s:a>
														<s:a href="userShop.htm?userId=%{#attr.row.userIdFav.userId}">View sellers shop</s:a>
														<a href="browseItems.htm?uid=<s:property value="%{#attr.row.userIdFav.id}" />&type=5">Advertisements</a>
														<s:a href="viewMyFeedback.htm?userId=%{#attr.row.userIdFav.id}&action=favoriteUsers">Feedback</s:a>
													</div>
												</td>
											</tr>
										</table>
									</display:column>
									<display:column>
										<tr>
											<td colspan="5" bgcolor="#ffffdd">
												<c:out value="${row.note}"></c:out>
											</td>
										</tr>
									</display:column>
								</display:table>
							</td>
						</tr>
						<tr>
							<td width="100%">
								<table border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td><img src="images/middle/btn-grey-left1.gif" alt=" " width="6" height="23" /></td>
										<td class="btn-grey-middle1 "><s:submit name="delete" value="delete" align="left" theme="simple" cssClass="submit-btn-common" /></td>
										<td><img src="images/middle/btn-grey-right1.gif" alt=" " width="6" height="23" /></td>
									</tr>
								</table>
							</td>
						</tr>
					</tbody>
				</table>
				</s:form>
			</div>
		</td>
	</tr>
</table>
